home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 8 / QRZ Ham Radio Callsign Database - Volume 8.iso / pc / files / sat / msat09.tgz / ELOGDISP.C < prev    next >
Text File  |  1994-09-17  |  4KB  |  125 lines

  1. /* SEU log display program for new format eltlog and eltlogxx files. */
  2. /* Use for UO-14 files after 04 April 1991.                          */
  3. /* Use for AO-16 and LO-19 files after March 1991.                   */
  4. /* File formatted for tab stops 3, 5, 7, etc                         */
  5. /* Structure contains NO slack bytes.                                */
  6. /* INTEL lsb-first ordering assumed.                                 */
  7.  
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <time.h>
  11.  
  12. #include "viewlog.h"
  13.  
  14. struct MEMERR
  15. {
  16.     long time        __attribute__ ((packed));                                                                        /* time of correction                */
  17.     unsigned short cluster    __attribute__ ((packed));                                                    /* cluster of error                    */
  18.     unsigned short sector    __attribute__ ((packed));                                                                        /* sector w/in cluster            */
  19.     unsigned short byte    __attribute__ ((packed));                                                                            /* byte w/in sector                    */
  20.     unsigned long fnumber    __attribute__ ((packed));                                                /* File in which error was    */
  21.     short severity        __attribute__ ((packed));                                                                    /* 0 none, 1 corrected,         */
  22.                                                                                                 /* 2 very bad.                            */
  23.                                                                                                 /* 3 seu in program RAM            */
  24.     char pattern        __attribute__ ((packed));                                                                    /* pattern for type 1                */
  25.     short function        __attribute__ ((packed));                                                                    /* reason for check                    */
  26. };
  27.  
  28. /* For MEMERR.function            */
  29. #define FUNC_WASH 1                                                            
  30. #define FUNC_READ 2
  31.  
  32. char writebuf[80];
  33.  
  34. /*------------------------------------------------------------------------
  35.     Funct    :        elogdisp
  36.     Date    :
  37.     Action    :    Displays the error log from the PCE.
  38.     ARGS    :
  39.     RETURNS    :
  40.     GLOBALS    :
  41. ------------------------------------------------------------------------*/
  42.  
  43. int elogdisp(FILE *fp)
  44. {
  45.     struct MEMERR seu;
  46.     char s1[30];
  47.  
  48.     writetext("SEU LOG:\n\n");
  49.     writetext("     Time             Cluster Sector  Byte  Patrn Type    File     Function\n");
  50.     writetext("-------------------   ------- ------  ----  ----- ----    -------  --------\n");
  51.  
  52.     while (!feof(fp))
  53.     {
  54.         if (fread(&seu, sizeof(struct MEMERR), 1, fp))
  55.         {
  56.                 /* Time, cluster and sector always valid */
  57.                 sprintf(s1, asctime(gmtime(&seu.time)));
  58.                 s1[strlen(s1)-1] = '\0';
  59.  
  60.                 sprintf(writebuf, "%20.20s  0x%04x  0x%04x  ", s1, seu.cluster, seu.sector);
  61.                 writetext(writebuf);
  62.  
  63.                 /* Byte only valid on correctable errors */
  64.                 if (seu.severity == 1)
  65.                 {
  66.                     sprintf(writebuf, "0x%02x  0x%02x  ", seu.byte, seu.pattern & 0xff);
  67.                     writetext(writebuf);
  68.                 }
  69.                 else
  70.                 {
  71.                     writetext("----- ");
  72.                     writetext("----- ");
  73.                 }
  74.  
  75.                 switch (seu.severity)
  76.                 {
  77.                     case 1:
  78.                         writetext("Fixed   ");
  79.                         break;
  80.  
  81.                     case 2:
  82.                         writetext("SEVERE  ");
  83.                         break;
  84.                 }
  85.  
  86.                 /* During WASH cycles, fnumber has 4 meanings */
  87.                 if (seu.function == FUNC_WASH)
  88.                 {
  89.                     if (seu.fnumber == 0l)
  90.                         writetext("Directry ");
  91.                     else if (seu.fnumber == -1l)
  92.                         writetext("in FAT   ");
  93.                     else if (seu.fnumber == -2l)
  94.                         writetext("in FREE  ");
  95.                     else
  96.                     {
  97.                         sprintf(writebuf, "%08lx ", seu.fnumber);
  98.                         writetext(writebuf);
  99.                     }
  100.                 }
  101.                 /* During READ cycles, fnumber has no meaning */
  102.                 else if (seu.function == FUNC_READ)
  103.                 {
  104.                     if (seu.fnumber < 1l)
  105.                         writetext("error    ");
  106.                     else
  107.                         writetext("unknown  ");
  108.                 }
  109.                 else
  110.                     writetext("bad func ");
  111.  
  112.                 /* Tell which function it was */
  113.                 if (seu.function == FUNC_WASH)
  114.                     writetext("Wash\n");
  115.                 else if (seu.function == FUNC_READ)
  116.                     writetext("Read\n");
  117.                 else writetext("????\n");
  118.  
  119.         }
  120.     }
  121.  
  122.     return(0);
  123. }
  124.  
  125.